﻿Imports System
Imports NUnit.Framework
Imports ValidationFramework

Namespace PropertyValidationManagerExamples
    Public Class ExternalExplicitExample
#Region "Example"
        Public Class Person
            Implements IPerson

            Private _age As Integer
            Private Property Age() As Integer Implements IPerson.Age
                Get
                    Return _age
                End Get
                Set(ByVal value As Integer)
                    _age = value
                End Set
            End Property

        End Class
        Public Interface IPerson
            <RequiredIntRule()> _
            Property Age() As Integer
        End Interface


        <TestFixture()> _
        Public Class ExampleUsage
            <Test()> _
            Public Sub Run()
                Dim person As IPerson = New Person()
                Dim propertyValidationManager = New PropertyValidationManager(person)
                'Could have called propertyValidationManager.Validate() here to validate all properties 
                propertyValidationManager.Validate("Age")
                Console.WriteLine(propertyValidationManager.IsValid)
                person.Age = 99
                'Could have called propertyValidationManager.Validate() here to validate all properties 
                propertyValidationManager.Validate("Age")
                Console.WriteLine(propertyValidationManager.IsValid)
                Console.ReadLine()
            End Sub
        End Class
#End Region
    End Class
End Namespace